package org.budo.graph.service.util;

import java.net.URL;

import org.budo.support.lang.util.IoUtil;
import org.budo.support.slf4j.Slf4j;
import org.slf4j.Logger;
import org.springframework.context.ApplicationContext;

/**
 * @author limingwei
 */
public class GitLogUtil {
    private static final Logger log = Slf4j.getLogger();

    public static String writeGitLogResponse(ApplicationContext applicationContext, String _url) {
        try {
            Thread currentThread = Thread.currentThread();
            ClassLoader contextClassLoader = currentThread.getContextClassLoader();
            URL url = contextClassLoader.getResource("git-log.txt");
            if (null == url) {
                return "NOT-FOUND";
            }

            return "<pre>" + IoUtil.toString(url.openStream()) + "</pre>";
        } catch (Throwable e) {
            log.error("#19 e=" + e, e);
            return "ERROR";
        }
    }
}